package com.hzxcloudserviceb.kafka;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Optional;

/**
 * Created by huzuxing on 2021/4/29.
 */
@Component
public class MessageConsumer {

    @KafkaListener(topics = {"wqh", "wanqh"})
    public void concume(ConsumerRecord<?, ?> consumerRecord) {
        Optional<?> message = Optional.ofNullable(consumerRecord);
        if (message.isPresent()) {
            Object msg = message.get();
            System.out.println("get message: " + msg);
        }
    }
}
